package com.hhly.rabbitmq.work;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;

import com.hhly.rabbitmq.RabbitMQUtil;
import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.AMQP.BasicProperties;
import com.rabbitmq.client.Channel;

public class SendTest {
	public static final String TASK_QUEUE_NAME = "sendticket_queue_test";

	public static void main(String[] args) {
		try {
			Channel channel = RabbitMQUtil.getChannel();
			Map<String, Object> map = new HashMap<>();
			map.put("x-max-priority", 10);
			channel.queueDeclare(TASK_QUEUE_NAME, false, false, false, map);
			BasicProperties properties = new AMQP.BasicProperties.Builder().priority(new Random().nextInt(10))
					.deliveryMode(2).build();
			String message = "Z1707161950400300012";
			channel.basicPublish("", TASK_QUEUE_NAME, properties, message.getBytes());
			System.out.println(message);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
